<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The structure of a Service Component</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sca.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sca.examples.proxies.html">Obtaining a proxy for another Service Component</a></div>
 <div class="up"><a href="sca.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sca.examples.structure" class="section">
  <h2 class="title">The structure of a Service Component</h2>
  <p class="para"> 
   A service component is implemented by a class. To identify it
   as a service component, it contains an @service annotation. The SCA
   runtime will use the file name of the script to determine the
   component name, by convention. The class and script file must
   therefore share the same name. 
  </p>
  
  <p class="para"> 
   PHP SCA components always expose a service, and there is no way
   for a component to be invoked other than to be called as a result of a
   Web service request, or called directly from another component or
   from a script. For this reason a valid PHP SCA component will always
   contain an @service annotation and at least one public method.
  </p>
  
  <p class="para"> 
   Each SCA Component requires that the SCA.php script is
   included. As well as containing the definition of the SCA class,
   this script contains executable PHP code that will run whenever the
   script is called, and which will be responsible for making the
   component behave as needed. 
  </p>
  
  <div class="caution"><strong class="caution">Caution</strong>
   
   <p class="para"> 
    It is very important that if your file contains other
    includes, they come before the include for SCA.php. If there are
    includes after the include for SCA.php, they will not have been
    processed when the SCA runtime runs your class. 
   </p>
  </div>
  
  <p class="para"> 
   The example below illustrates this overall structure
  </p>
  
  <p class="para">
   <div class="example" id="example-5179">
    <p><strong>Example #1  The structure of an SCA for PHP component </strong></p>
    
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;any&nbsp;includes<br /><br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">"SCA/SCA.php"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;@service<br />&nbsp;*/<br /><br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">ConvertedStockQuote&nbsp;</span><span style="color: #007700">{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;instance&nbsp;variables,&nbsp;business&nbsp;logic,&nbsp;including&nbsp;at&nbsp;least&nbsp;one&nbsp;public&nbsp;method<br /><br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sca.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sca.examples.proxies.html">Obtaining a proxy for another Service Component</a></div>
 <div class="up"><a href="sca.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
